package week03;

import java.util.Scanner;

public class Rational
{
	private int v1;
	private int v2;
	
	public Rational(int v1,int v2)
	{
		this.v1=v1;
		this.v2=v2;
	}
	
	public int getV1() {
		return v1;
	}

	public void setV1(int v1) {
		this.v1 = v1;
	}

	public int getV2() {
		return v2;
	}

	public void setV2(int v2) {
		this.v2 = v2;
	}

	public static  Rational Add(Rational T1,Rational T2)
	{
		int p,q,t;
		p=T1.v1*T2.v2+T2.v1*T1.v2;
		q=T1.v2*T2.v2;
		t=Gcd(p,q);
		Rational T=new Rational(p/t,q/t);
		return T;
	}

	public static  Rational Multiply(Rational T1,Rational T2)
	{
		int p,q,t;
		q=T1.v2*T2.v2;
		p=T1.v1*T2.v1;
		t=Gcd(p,q);
		Rational T=new Rational(p/t,q/t);
		return T;
	}
	
    public static int Gcd(int m,int n)
    {
    	int t;
    	while(m%n!=0)
    	{
    		t=n;
    		n=m%n;
    		m=t;
    	}
    	return n;
    } 
    
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		Rational T1=new Rational(in.nextInt(),in.nextInt());
		Rational T2=new Rational(in.nextInt(),in.nextInt());
		System.out.printf("%d %d\n",Add(T1,T2).v1,Add(T1,T2).v2);
		System.out.printf("%d %d",Multiply(T1,T2).v1, Multiply(T1,T2).v2);
	}
}